package com.shop.front.dao.user;


import com.shop.front.vo.store.CollectProductVo;
import com.shop.jpa.BaseSQLDao;
import com.shop.jpa.support.QuerySQL;
import com.shop.web.context.WebContext;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Repository;

@Repository
public class CollectSQLDao extends BaseSQLDao {


    public Page<CollectProductVo> page(Long userId) {
        String field = "sc.id, sc.product_id, sp.*";
        String from = "t_collect sc left join t_store_product sp on sc.product_id = sp.id ";
        String order = "sc.id desc";

        QuerySQL qs = new QuerySQL(WebContext.getPageNo(), WebContext.getPageSize(), field, from, order);
        qs.addWhereWithoutParams("sc.is_deleted = 0 and sp.is_deleted = 0 ");
        qs.addWhereEq("sc.user_id", userId);

        return this.page(qs, CollectProductVo.class);
    }



}
